package models;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.*;

import java.util.Date;
import java.util.Set;

/**
 * The persistent class for the wm$wallet database table.
 * 
 */
@Entity
@Table(name = "WM$WALLET")
public class WmWallet  implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(unique = true, nullable = false)
    private int id;

    private BigDecimal balance;

    @Column(name = "BALANCE_LOCKED_FOR_INVEST")
    private BigDecimal balanceLockedForInvest;

    @Column(name = "BALANCE_LOCKED_FOR_PENDING")
    private BigDecimal balancePendingForInvest;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "CREATE_D")
    private Date createD;

    @Column(length = 20)
    private String name;

    @Column(name = "PENDING_LOADS")
    private BigDecimal pendingLoads;

    @Column(name = "PENDING_WITHDRAW")
    private BigDecimal pendingWithdraw;

    @Column(name = "STATUS")
    private int status;

    @Column(name = "TYPE")
    private int type;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "UPDATE_D")
    private Date updateD;

    public WmWallet() {
        initialBalance();
    }

    public WmWallet(Status status, Type type) {
        super();
        this.status = status.ordinal();
        this.type = type.ordinal();
        this.initialBalance();
        this.createD = new Date();
        this.updateD = new Date();
    }

    private void initialBalance() {
        balance = BigDecimal.ZERO;
        pendingLoads = BigDecimal.ZERO;
        pendingWithdraw = BigDecimal.ZERO;
        balanceLockedForInvest = BigDecimal.ZERO;
        balancePendingForInvest = BigDecimal.ZERO;
    }

    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public BigDecimal getBalance() {
        return this.balance;
    }

    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    }

    public BigDecimal getBalanceLockedForInvest() {
        return this.balanceLockedForInvest;
    }

    public void setBalanceLockedForInvest(BigDecimal balanceLockedForInvest) {
        this.balanceLockedForInvest = balanceLockedForInvest;
    }

    public BigDecimal getBalancePendingForInvest() {
        return this.balancePendingForInvest;
    }

    public void setBalancePendingForInvest(BigDecimal balanceLockedForPending) {
        this.balancePendingForInvest = balanceLockedForPending;
    }

    public Date getCreateD() {
        return this.createD;
    }

    public void setCreateD(Date createD) {
        this.createD = createD;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getPendingLoads() {
        return this.pendingLoads;
    }

    public void setPendingLoads(BigDecimal pendingLoads) {
        this.pendingLoads = pendingLoads;
    }

    public BigDecimal getPendingWithdraw() {
        return this.pendingWithdraw;
    }

    public void setPendingWithdraw(BigDecimal pendingWithdraw) {
        this.pendingWithdraw = pendingWithdraw;
    }

    public Status getStatus() {
        Status[] vals = Status.values();
        if (this.type > vals.length - 1 || this.type < 0)
            return null;
        return Status.values()[this.type];
    }

    public void setStatus(Status status) {
        this.status = status.ordinal();
    }

    public Type getType() {
        Type[] vals = Type.values();
        if (this.type > vals.length - 1 || this.type < 0)
            return null;
        return Type.values()[this.type];
    }

    public void setType(Type type) {
        this.type = type.ordinal();
    }

    public Date getUpdateD() {
        return this.updateD;
    }

    public void setUpdateD(Date updateD) {
        this.updateD = updateD;
    }

    public enum Status {
        ACTIVE, // 0
        DISABLE, // 1
    }

    public enum Type {
        CUSTOMER, // 0
        SYSTEM, // 1
    }

}